\ No newline at end of file
diff --git a/plugin/Live/Live.php b/plugin/Live/Live.php
index be0d68484..045f47db1 100644
--- a/plugin/Live/Live.php
+++ b/plugin/Live/Live.php
@@ -1,1225 +1,1440 @@
and receive HLS streaming from servers";
$lu = AVideoPlugin::loadPlugin("LiveUsers");
if (!empty($lu)) {
if (version_compare($lu->getPluginVersion(), "2.0") < 0) {
$desc .= "
You MUST update your LiveUsers plugin to version 2.0 or greater
";
}
}
return $desc;
}
public function getName() {
return "Live";
}
public function getHTMLMenuRight() {
global $global;
$buttonTitle = $this->getButtonTitle();
$obj = $this->getDataObject();
if (!empty($obj->hideTopButton)) {
return '';
}
include $global['systemRootPath'] . 'plugin/Live/view/menuRight.php';
}
public function getUUID() {
return "e06b161c-cbd0-4c1d-a484-71018efa2f35";
}
public function getPluginVersion() {
return "5.2";
}
public function updateScript() {
global $global;
//update version 2.0
$sql = "SELECT 1 FROM live_transmitions_history LIMIT 1";
$res = sqlDAL::readSql($sql);
$fetch = sqlDAL::fetchAssoc($res);
if (!$fetch) {
sqlDal::writeSql(file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV2.0.sql'));
}
//update version 3.0
$sql = "SELECT 1 FROM live_transmition_history_log LIMIT 1";
$res = sqlDAL::readSql($sql);
$fetch = sqlDAL::fetchAssoc($res);
if (!$fetch) {
sqlDal::writeSql(file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV3.0.sql'));
}
//update version 4.0
$sql = "SELECT 1 FROM live_servers LIMIT 1";
$res = sqlDAL::readSql($sql);
$fetch = sqlDAL::fetchAssoc($res);
if (!$fetch) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV4.0.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
//update version 5.0
$sql = "SELECT 1 FROM live_restreams LIMIT 1";
$res = sqlDAL::readSql($sql);
$fetch = sqlDAL::fetchAssoc($res);
if (!$fetch) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.0.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
//update version 5.1
if (AVideoPlugin::compareVersion($this->getName(), "5.1") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.1.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
//update version 5.2
if (AVideoPlugin::compareVersion($this->getName(), "5.2") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.2.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
//update version 5.2
if (AVideoPlugin::compareVersion($this->getName(), "6.0") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV6.0.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSql(trim($value));
}
}
return true;
}
public function getEmptyDataObject() {
global $global;
$server = parse_url($global['webSiteRootURL']);
$scheme = "http";
$port = "8080";
if (strtolower($server["scheme"]) == "https") {
$scheme = "https";
$port = "8443";
}
$obj = new stdClass();
$obj->button_title = "LIVE";
self::addDataObjectHelper('button_title', 'Button Title', 'This is the title that will appear in your button to enter in the Live panel');
$obj->server = "rtmp://{$server['host']}/live";
- self::addDataObjectHelper('server', 'RTMP Server URL', 'Usually it is '."rtmp://{$server['host']}/live");
+ self::addDataObjectHelper('server', 'RTMP Server URL', 'Usually it is ' . "rtmp://{$server['host']}/live");
$obj->playerServer = "{$scheme}://{$server['host']}:{$port}/live";
- self::addDataObjectHelper('playerServer', 'Player URL', 'This is a URL to your NGINX server, this URL will be used by the HTML5 player, If your site is HTTPS your player URL MUST be HTTPS as well, usually it is '."{$scheme}://{$server['host']}:{$port}/live");
+ self::addDataObjectHelper('playerServer', 'Player URL', 'This is a URL to your NGINX server, this URL will be used by the HTML5 player, If your site is HTTPS your player URL MUST be HTTPS as well, usually it is ' . "{$scheme}://{$server['host']}:{$port}/live");
$obj->stats = "{$scheme}://{$server['host']}:{$port}/stat";
- self::addDataObjectHelper('stats', 'Stats Page URL', 'When you installed the NGINX you also install the stat.xsl, we will use it to grab the information when you have livestreams running, usually it is '."{$scheme}://{$server['host']}:{$port}/stat");
+ self::addDataObjectHelper('stats', 'Stats Page URL', 'When you installed the NGINX you also install the stat.xsl, we will use it to grab the information when you have livestreams running, usually it is ' . "{$scheme}://{$server['host']}:{$port}/stat");
$obj->restreamerURL = "{$global['webSiteRootURL']}plugin/Live/standAloneFiles/restreamer.json.php";
self::addDataObjectHelper('restreamerURL', 'Restreamer URL', 'https://github.com/WWBN/AVideo/wiki/Restream');
$obj->controlURL = "{$global['webSiteRootURL']}plugin/Live/standAloneFiles/control.json.php";
self::addDataObjectHelper('controlURL', 'Control URL', 'Still under development');
$obj->disableRestream = false;
self::addDataObjectHelper('disableRestream', 'Disable Restream', 'If you check this, we will not send requests to your Restreamer URL');
$obj->disableDVR = false;
self::addDataObjectHelper('disableDVR', 'Disable DVR', 'Enable or disable the DVR Feature, you can control the DVR length in your nginx.conf on the parameter hls_playlist_length');
$obj->disableGifThumbs = false;
self::addDataObjectHelper('disableGifThumbs', 'Disable Gif Thumbs', 'This option will disable the Animated Gif render, it will save some hardware capacity from your encoder and may speedup your page');
$obj->disableLiveThumbs = false;
self::addDataObjectHelper('disableLiveThumbs', 'Disable Live thumbnails', 'This option will disable the çive image extraction and will use the user static image, it will save some hardware capacity from your encoder and may speedup your page');
$obj->hideTopButton = false;
self::addDataObjectHelper('hideTopButton', 'Hide Top Button', 'This will hide the "Go Live" button on the top menu bar');
$obj->useAadaptiveMode = false;
self::addDataObjectHelper('useAadaptiveMode', 'Adaptive mode', 'https://github.com/WWBN/AVideo/wiki/Adaptive-Bitrates-on-Livestream');
$obj->protectLive = false;
self::addDataObjectHelper('protectLive', 'Live Protection', 'With this your encryption key will be protected, and only your site player will be able to play your videos, download tools will not be able to download your video. if you want to share your live externally you can use the embed and you will still be protected. but if you want to use the m3u8 file you must disable this');
$obj->experimentalWebcam = false;
self::addDataObjectHelper('experimentalWebcam', 'Experimental Webcam', 'Requires flash and it is deprecated, will be removed. not recommend to enable it.');
$obj->doNotShowLiveOnVideosList = false;
self::addDataObjectHelper('doNotShowLiveOnVideosList', 'Do not show live on videos list', 'We will not show the live thumbs on the main Gallery page');
+ $obj->doNotShowLiveOnCategoryList = false;
+ self::addDataObjectHelper('doNotShowLiveOnCategoryList', 'Do not show live on site category list', 'We will not show the live thumbs on the main Gallery page');
+ $obj->doNotShowOfflineLiveOnCategoryList = false;
+ self::addDataObjectHelper('doNotShowOfflineLiveOnCategoryList', 'Do not show offline lives on site category list', 'We will not show the live thumbs on the main Gallery page if it is offline');
$obj->limitLiveOnVideosList = 12;
self::addDataObjectHelper('limitLiveOnVideosList', 'Videos List Limit', 'This will limit the maximum of videos that you will see in the Videos page');
//$obj->doNotShowGoLiveButton = false;
//self::addDataObjectHelper('doNotShowGoLiveButton', 'Hide Top Button', 'This will hide the "Go Live" button on the top menu bar');
$obj->doNotProcessNotifications = false;
self::addDataObjectHelper('doNotProcessNotifications', 'Do not show notifications', 'Do not show the notification on the top bar');
$obj->useLiveServers = false;
self::addDataObjectHelper('useLiveServers', 'Use Live Servers', 'Check this if you will use External Live Servers https://github.com/WWBN/AVideo/wiki/Live-Plugin#livestream-server-balance ');
$obj->disableMeetCamera = false;
self::addDataObjectHelper('disableMeetCamera', 'Disable Meet camera', 'This requires out Meet Server, with the Meet camera you can use your PC webcam directly in the webpage or mobile to make livestreams');
$obj->playLiveInFullScreen = false;
self::addDataObjectHelper('playLiveInFullScreen', 'Play Livestream in Full Screen');
$obj->hls_path = "/HLS/live";
self::addDataObjectHelper('hls_path', 'HLS Path URL', 'Used only when we stop a Live, we use this path to delete the files');
$obj->requestStatsTimout = 4; // if the server does not respond we stop wait
self::addDataObjectHelper('requestStatsTimout', 'Stats Timout', 'If a remote server (stats page) does not respond we stop waiting after this timeout');
$obj->cacheStatsTimout = 15; // we will cache the result
self::addDataObjectHelper('cacheStatsTimout', 'Stats Cache Timeout', 'we will cache the result, this will save some resources');
$obj->requestStatsInterval = 15; // how many seconds untill request the stats again
self::addDataObjectHelper('requestStatsInterval', 'Stats Request Interval', 'how many seconds until request the stats again');
$obj->streamDeniedMsg = "You can not stream live videos";
self::addDataObjectHelper('streamDeniedMsg', 'Denied Message', 'We will show this message when a user is not allowed so watch a livestream');
+
return $obj;
}
-
-
+
public function getHeadCode() {
global $global;
$obj = $this->getDataObject();
// preload image
$js = "";
$css = '';
-
- if(!empty($obj->playLiveInFullScreen)){
- if((isLive() || isEmbed()) && canFullScreen()){
+
+ if (!empty($obj->playLiveInFullScreen)) {
+ if ((isLive() || isEmbed()) && canFullScreen()) {
$css .= '';
$css .= '';
}
$js .= '';
$css .= '';
}
- return $js.$css;
+ return $js . $css;
}
-
+
public function getFooterCode() {
$obj = $this->getDataObject();
global $global;
-
+
$js = '';
- if(!empty($obj->playLiveInFullScreen)){
+ if (!empty($obj->playLiveInFullScreen)) {
$js = '';
$js .= '';
-
}
return $js;
}
public function getButtonTitle() {
$o = $this->getDataObject();
return $o->button_title;
}
public function getKey() {
$o = $this->getDataObject();
return $o->key;
}
static function getDestinationApplicationName() {
$server = self::getPlayerServer();
$server = rtrim($server, "/");
$parts = explode("/", $server);
$app = array_pop($parts);
$domain = self::getControl();
//return "{$domain}/control/drop/publisher?app={$app}&name={$key}";
return "{$app}?p=" . User::getUserPass();
}
static function getDestinationHost() {
$server = self::getServer();
$host = parse_url($server, PHP_URL_HOST);
return $host;
}
static function getDestinationPort() {
$server = self::getServer();
$port = parse_url($server, PHP_URL_PORT);
if (empty($port)) {
$port = 1935;
}
return $port;
}
static function getServer($live_servers_id = -1) {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->useLiveServers)) {
if ($live_servers_id < 0) {
$live_servers_id = self::getCurrentLiveServersId();
}
$ls = new Live_servers($live_servers_id);
if (!empty($ls->getRtmp_server())) {
return $ls->getRtmp_server();
}
}
return $obj->server;
}
static function getDropURL($key) {
$server = self::getPlayerServer();
$server = rtrim($server, "/");
$parts = explode("/", $server);
$app = array_pop($parts);
$domain = self::getControl();
//return "{$domain}/control/drop/publisher?app={$app}&name={$key}";
return "{$domain}?command=drop_publisher&app={$app}&name={$key}&token=" . getToken(60);
}
static function getIsRecording($key) {
$server = self::getPlayerServer();
$server = rtrim($server, "/");
$parts = explode("/", $server);
$app = array_pop($parts);
$domain = self::getControl();
//return "{$domain}/control/drop/publisher?app={$app}&name={$key}";
return "{$domain}?command=is_recording&app={$app}&name={$key}&token=" . getToken(60);
}
static function getStartRecordURL($key) {
$server = self::getPlayerServer();
$server = rtrim($server, "/");
$parts = explode("/", $server);
$app = array_pop($parts);
$domain = self::getControl();
//return "{$domain}/control/drop/publisher?app={$app}&name={$key}";
return "{$domain}?command=record_start&app={$app}&name={$key}&token=" . getToken(60);
}
static function getStopRecordURL($key) {
$server = self::getPlayerServer();
$server = rtrim($server, "/");
$parts = explode("/", $server);
$app = array_pop($parts);
$domain = self::getControl();
return "{$domain}?command=record_stop&app={$app}&name={$key}&token=" . getToken(60);
}
static function getButton($command, $live_transmition_id, $live_servers_id = 0, $iconsOnly = false, $label = "", $class = "", $tooltip = "") {
if (!User::canStream()) {
return "";
}
global $global;
$id = "getButton" . uniqid();
if (empty($live_servers_id)) {
$live_servers_id = self::getLiveServersIdRequest();
}
switch ($command) {
case "record_start":
$buttonClass = "btn btn-default btn-sm";
$iconClass = "fas fa-video";
if (empty($label)) {
$label = __("Start Record");
}
if (empty($tooltip)) {
$tooltip = __("Start Record");
}
break;
case "record_stop":
$buttonClass = "btn btn-default btn-sm";
$iconClass = "fas fa-video-slash";
if (empty($label)) {
$label = __("Stop Record");
}
if (empty($tooltip)) {
$tooltip = __("Stop Record");
}
break;
case "drop_publisher":
$buttonClass = "btn btn-default btn-sm";
$iconClass = "fas fa-wifi";
if (empty($label)) {
$label = __("Disconnect Livestream");
}
if (empty($tooltip)) {
$tooltip = __("Disconnect Livestream");
}
break;
case "drop_publisher_reset_key":
$buttonClass = "btn btn-default btn-sm";
$iconClass = "fas fa-key";
if (empty($label)) {
$label = __("Disconnect Livestream");
}
if (empty($tooltip)) {
$tooltip = __("Disconnect Livestream") . __(" and also reset the stream name/key");
}
break;
default:
return '';
}
if ($iconsOnly) {
$label = "";
}
$html = "";
return $html;
}
static function getRecordControlls($live_transmition_id, $live_servers_id = 0, $iconsOnly = false) {
if (!User::canStream()) {
return "";
}
$btn = "
";
return $btn;
}
static function getRestreamer($live_servers_id = -1) {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->useLiveServers)) {
if ($live_servers_id < 0) {
$live_servers_id = self::getCurrentLiveServersId();
}
$ls = new Live_servers($live_servers_id);
if (!empty($ls->getRestreamerURL())) {
return $ls->getRestreamerURL();
}
}
return $obj->restreamerURL;
}
static function getControl($live_servers_id = -1) {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->controlURL)) {
if ($live_servers_id < 0) {
$live_servers_id = self::getCurrentLiveServersId();
}
$ls = new Live_servers($live_servers_id);
if (!empty($ls->getControlURL())) {
return $ls->getControlURL();
}
}
return $obj->controlURL;
}
static function getRTMPLink($users_id) {
if (!User::isLogged() || ($users_id !== User::getId() && !User::isAdmin())) {
return false;
}
$user = new User($users_id);
$trasnmition = LiveTransmition::createTransmitionIfNeed($users_id);
return self::getServer() . "?p=" . $user->getPassword() . "/" . $trasnmition['key'];
}
static function getPlayerServer() {
$obj = AVideoPlugin::getObjectData("Live");
$url = $obj->playerServer;
if (!empty($obj->useLiveServers)) {
$ls = new Live_servers(self::getCurrentLiveServersId());
if (!empty($ls->getPlayerServer())) {
$url = $ls->getPlayerServer();
}
}
- $url = str_replace("encoder.gdrive.local","192.168.1.18", $url);
+ $url = str_replace("encoder.gdrive.local", "192.168.1.18", $url);
return $url;
}
static function getUseAadaptiveMode() {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->useLiveServers)) {
$ls = new Live_servers(self::getCurrentLiveServersId());
return $ls->getUseAadaptiveMode();
}
return $obj->useAadaptiveMode;
}
static function getRemoteFile() {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->useLiveServers)) {
$ls = new Live_servers(self::getCurrentLiveServersId());
return $ls->getGetRemoteFile();
}
return false;
}
static function getRemoteFileFromRTMPHost($rtmpHostURI) {
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj->useLiveServers)) {
$live_servers_id = Live_servers::getServerIdFromRTMPHost($rtmpHostURI);
if ($live_servers_id) {
$ls = new Live_servers($live_servers_id);
return $ls->getGetRemoteFile();
}
}
return false;
}
static function getLiveServersIdRequest() {
if (empty($_REQUEST['live_servers_id'])) {
return 0;
}
return intval($_REQUEST['live_servers_id']);
}
static function getM3U8File($uuid, $doNotProtect = false) {
global $global;
$o = AVideoPlugin::getObjectData("Live");
$playerServer = self::getPlayerServer();
$live_servers_id = self::getLiveServersIdRequest();
$liveServer = new Live_servers($live_servers_id);
if ($liveServer->getStats_url()) {
$o->protectLive = $liveServer->getProtectLive();
$o->useAadaptiveMode = $liveServer->getUseAadaptiveMode();
}
-
+
$uuid = LiveTransmition::keyNameFix($uuid);
-
+
if ($o->protectLive && empty($doNotProtect)) {
return "{$global['webSiteRootURL']}plugin/Live/m3u8.php?live_servers_id={$live_servers_id}&uuid=" . encryptString($uuid);
} else if ($o->useAadaptiveMode) {
return $playerServer . "/{$uuid}.m3u8";
} else {
return $playerServer . "/{$uuid}/index.m3u8";
}
}
public function getDisableGifThumbs() {
$o = $this->getDataObject();
return $o->disableGifThumbs;
}
public function getStatsURL($live_servers_id = 0) {
global $global;
$o = $this->getDataObject();
if (!empty($live_servers_id)) {
$liveServer = new Live_servers($live_servers_id);
if ($liveServer->getStats_url()) {
return $liveServer->getStats_url();
}
}
return $o->stats;
}
public function getChat($uuid) {
global $global;
//check if LiveChat Plugin is available
$filename = $global['systemRootPath'] . 'plugin/LiveChat/LiveChat.php';
if (file_exists($filename)) {
require_once $filename;
LiveChat::includeChatPanel($uuid);
}
}
function getStatsObject($live_servers_id = 0) {
if (!function_exists('simplexml_load_file')) {
_error_log("Live::getStatsObject: You need to install the simplexml_load_file function to be able to see the Live stats", AVideoLog::$ERROR);
return false;
}
global $getStatsObject;
if (!empty($getStatsObject[$live_servers_id])) {
return $getStatsObject[$live_servers_id];
}
$o = $this->getDataObject();
if ($o->doNotProcessNotifications) {
$xml = new stdClass();
$xml->server = new stdClass();
$xml->server->application = array();
return $xml;
}
if (empty($o->requestStatsTimout)) {
$o->requestStatsTimout = 2;
}
ini_set('allow_url_fopen ', 'ON');
$url = $this->getStatsURL($live_servers_id);
if (!empty($_SESSION['getStatsObjectRequestStatsTimout'][$url])) {
_error_log("Live::getStatsObject RTMP Server ($url) is NOT responding we will wait less from now on => live_servers_id = ($live_servers_id) ");
// if the server already fail, do not wait mutch for it next time, just wait 0.5 seconds
$o->requestStatsTimout = $_SESSION['getStatsObjectRequestStatsTimout'][$url];
}
$data = $this->get_data($url, $o->requestStatsTimout);
if (empty($data)) {
if (empty($_SESSION['getStatsObjectRequestStatsTimout'][$url])) {
// the server fail to respont, just wait 0.5 seconds until it respond again
_session_start();
if (empty($_SESSION['getStatsObjectRequestStatsTimout'])) {
$_SESSION['getStatsObjectRequestStatsTimout'] = array();
}
$_SESSION['getStatsObjectRequestStatsTimout'][$url] = 0.5;
}
_error_log("Live::getStatsObject RTMP Server ($url) is OFFLINE, we could not connect on it => live_servers_id = ($live_servers_id) ", AVideoLog::$ERROR);
$data = 'The RTMP Server is Unavailable0';
} else {
if (!empty($_SESSION['getStatsObjectRequestStatsTimout'][$url])) {
_error_log("Live::getStatsObject RTMP Server ($url) is respond again => live_servers_id = ($live_servers_id) ");
// the server respont again, wait the default time
_session_start();
$_SESSION['getStatsObjectRequestStatsTimout'][$url] = 0;
unset($_SESSION['getStatsObjectRequestStatsTimout'][$url]);
}
}
$xml = simplexml_load_string($data);
$getStatsObject[$live_servers_id] = $xml;
return $xml;
}
function get_data($url, $timeout) {
try {
$content = @url_get_contents($url, "", $timeout);
return $content;
} catch (Exception $exc) {
_error_log($exc->getTraceAsString());
}
return false;
}
public function getChartTabs() {
return '
';
}
public function getChartContent() {
global $global;
include $global['systemRootPath'] . 'plugin/Live/report.php';
}
static public function saveHistoryLog($key) {
// get the latest history for this key
$latest = LiveTransmitionHistory::getLatest($key);
if (!empty($latest)) {
LiveTransmitionHistoryLog::addLog($latest['id']);
}
}
public function dataSetup() {
$obj = $this->getDataObject();
if (!isLive() || $obj->disableDVR) {
return "";
}
return "liveui: true";
}
static function stopLive($users_id) {
if (!User::isAdmin() && User::getId() != $users_id) {
return false;
}
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj)) {
$server = str_replace("stats", "", $obj->stats);
$lt = new LiveTransmition(0);
$lt->loadByUser($users_id);
$key = $lt->getKey();
$appName = self::getApplicationName();
$url = "{$server}control/drop/publisher?app={$appName}&name=$key";
url_get_contents($url);
$dir = $obj->hls_path . "/$key";
if (is_dir($dir)) {
exec("rm -fR $dir");
rrmdir($dir);
}
}
}
// not implemented yet
static function startRecording($users_id) {
if (!User::isAdmin() && User::getId() != $users_id) {
return false;
}
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj)) {
$server = str_replace("stats", "", $obj->stats);
$lt = new LiveTransmition(0);
$lt->loadByUser($users_id);
$key = $lt->getKey();
$appName = self::getApplicationName();
$url = "{$server}control/record/start?app={$appName}&name=$key";
url_get_contents($url);
}
}
static function getApplicationName() {
$obj = AVideoPlugin::getObjectData('Live');
$parts = explode("/", $obj->playerServer);
$live = end($parts);
if (empty($live)) {
$live = "live";
}
return $live;
}
// not implemented yet
static function stopRecording($users_id) {
if (!User::isAdmin() && User::getId() != $users_id) {
return false;
}
$obj = AVideoPlugin::getObjectData("Live");
if (!empty($obj)) {
$server = str_replace("stats", "", $obj->stats);
$lt = new LiveTransmition(0);
$lt->loadByUser($users_id);
$key = $lt->getKey();
$appName = self::getApplicationName();
$url = "{$server}control/record/stop?app={$appName}&name=$key";
url_get_contents($url);
}
}
static function getLinkToLiveFromUsers_id($users_id) {
$live_servers_id = self::getCurrentLiveServersId();
return self::getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id);
}
static function getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id) {
if (empty($users_id)) {
return false;
}
global $global;
$user = new User($users_id);
if (empty($user->getChannelName())) {
return false;
}
return self::getLinkToLiveFromChannelNameAndLiveServer($user->getChannelName(), $live_servers_id);
}
static function getLinkToLiveFromChannelNameAndLiveServer($channelName, $live_servers_id) {
global $global;
$live_servers_id = intval($live_servers_id);
$channelName = trim($channelName);
if (empty($channelName)) {
return false;
}
$playlists_id_live = "";
- if(!empty($_REQUEST['playlists_id_live'])){
- $playlists_id_live = "?playlists_id_live=".$_REQUEST['playlists_id_live'];
+ if (!empty($_REQUEST['playlists_id_live'])) {
+ $playlists_id_live = "?playlists_id_live=" . $_REQUEST['playlists_id_live'];
}
//return "{$global['webSiteRootURL']}plugin/Live/?live_servers_id={$live_servers_id}&c=" . urlencode($channelName);
- return "{$global['webSiteRootURL']}live/{$live_servers_id}/" . urlencode($channelName).$playlists_id_live;
+ return "{$global['webSiteRootURL']}live/{$live_servers_id}/" . urlencode($channelName) . $playlists_id_live;
}
static function getAvailableLiveServersId() {
$ls = self::getAvailableLiveServer();
if (empty($ls)) {
return 0;
} else {
return intval($ls->live_servers_id);
}
}
-
+
static function getLastServersIdFromUser($users_id) {
$last = LiveTransmitionHistory::getLatestFromUser($users_id);
if (empty($last)) {
return 0;
} else {
return intval($last['live_servers_id']);
}
}
-
- static function getLinkToLiveFromUsers_idWithLastServersId($users_id){
+
+ static function getLinkToLiveFromUsers_idWithLastServersId($users_id) {
$live_servers_id = self::getLastServersIdFromUser($users_id);
return self::getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id);
}
-
+
static function getCurrentLiveServersId() {
$live_servers_id = self::getLiveServersIdRequest();
if ($live_servers_id) {
return $live_servers_id;
} else {
return self::getAvailableLiveServersId();
}
}
public function getVideosManagerListButtonTitle() {
global $global;
if (!User::isAdmin()) {
return "";
}
$btn = '';
return $btn;
}
public function getPluginMenu() {
global $global;
return ' ' . __('Edit Live Servers') . '';
}
static function getStats() {
+ global $getStatsLive;
+ if (isset($getStatsLive)) {
+ return $getStatsLive;
+ }
$obj = AVideoPlugin::getObjectData("Live");
if (empty($obj->useLiveServers)) {
- return self::_getStats(0);
+ $getStatsLive = self::_getStats(0);
+ return $getStatsLive;
} else if (!empty(Live::getLiveServersIdRequest())) {
$ls = new Live_servers(Live::getLiveServersIdRequest());
if (!empty($ls->getPlayerServer())) {
$server = self::_getStats($ls->getId());
$server->live_servers_id = $ls->getId();
$server->playerServer = $ls->getPlayerServer();
+ $getStatsLive = $server;
return $server;
}
}
$ls = Live_servers::getAllActive();
$liveServers = array();
$getLiveServersIdRequest = self::getLiveServersIdRequest();
foreach ($ls as $value) {
$server = Live_servers::getStatsFromId($value['id']);
if (!empty($server) && is_object($server)) {
$server->live_servers_id = $value['id'];
$server->playerServer = $value['playerServer'];
foreach ($server->applications as $key => $app) {
$_REQUEST['live_servers_id'] = $value['id'];
if (empty($app['key'])) {
$app['key'] = "";
}
$server->applications[$key]['m3u8'] = self::getM3U8File($app['key']);
}
$liveServers[] = $server;
} else {
_error_log("Live::getStats Live Server NOT found {$value['id']} " . json_encode($server) . " " . json_encode($value));
}
}
$_REQUEST['live_servers_id'] = $getLiveServersIdRequest;
+ $getStatsLive = $liveServers;
return $liveServers;
}
static function getAllServers() {
$obj = AVideoPlugin::getObjectData("Live");
if (empty($obj->useLiveServers)) {
return array("id" => 0, "name" => __("Default"), "status" => "a", "rtmp_server" => $obj->server, 'playerServer' => $obj->playerServer, "stats_url" => $obj->stats, "disableDVR" => $obj->disableDVR, "disableGifThumbs" => $obj->disableGifThumbs, "useAadaptiveMode" => $obj->useAadaptiveMode, "protectLive" => $obj->protectLive, "getRemoteFile" => "");
} else {
return Live_servers::getAllActive();
}
}
static function getAvailableLiveServer() {
// create 1 min cache
$name = "Live::getAvailableLiveServer";
$return = ObjectYPT::getCache($name, 60);
if (empty($return)) {
$obj = AVideoPlugin::getObjectData("Live");
if (empty($obj->useLiveServers)) {
$return = false;
} else {
$liveServers = self::getStats();
usort($liveServers, function($a, $b) {
if ($a->countLiveStream == $b->countLiveStream) {
return 0;
}
return ($a->countLiveStream < $b->countLiveStream) ? -1 : 1;
});
if (empty($liveServers[0])) {
_error_log("Live::getAvailableLiveServer we could not get server status, try to uncheck useLiveServers parameter from the Live plugin");
return array();
}
$return = $liveServers[0];
ObjectYPT::setCache($name, $return);
}
}
return $return;
}
static function canSeeLiveFromLiveKey($key) {
$lt = self::getLiveTransmitionObjectFromKey($key);
- if(empty($lt)){
+ if (empty($lt)) {
return false;
}
return $lt->userCanSeeTransmition();
}
-
-
+
static function isAPrivateLiveFromLiveKey($key) {
$lt = self::getLiveTransmitionObjectFromKey($key);
- if(empty($lt)){
+ if (empty($lt)) {
return false;
}
return $lt->isAPrivateLive();
}
-
+
static function getLiveTransmitionObjectFromKey($key) {
global $getLiveTransmitionObjectFromKey;
- if(empty($getLiveTransmitionObjectFromKey)){
+ if (empty($getLiveTransmitionObjectFromKey)) {
$getLiveTransmitionObjectFromKey = array();
}
$parts = explode("_", $key);
if (empty($parts[0])) {
return false;
}
- if(!isset($getLiveTransmitionObjectFromKey[$parts[0]])){
+ if (!isset($getLiveTransmitionObjectFromKey[$parts[0]])) {
$livet = LiveTransmition::keyExists($parts[0]);
if (empty($livet)) {
$getLiveTransmitionObjectFromKey[$parts[0]] = false;
} else {
$lt = new LiveTransmition($livet['id']);
$getLiveTransmitionObjectFromKey[$parts[0]] = $lt;
}
}
return $getLiveTransmitionObjectFromKey[$parts[0]];
-
}
static function _getStats($live_servers_id = 0) {
global $global, $_getStats;
if (empty($_REQUEST['name'])) {
//_error_log("Live::_getStats {$live_servers_id} GET " . json_encode($_GET));
//_error_log("Live::_getStats {$live_servers_id} POST " . json_encode($_POST));
//_error_log("Live::_getStats {$live_servers_id} REQUEST " . json_encode($_REQUEST));
$_REQUEST['name'] = "undefined";
}
if (!empty($_getStats[$live_servers_id][$_REQUEST['name']]) && is_object($_getStats[$live_servers_id][$_REQUEST['name']])) {
//_error_log("Live::_getStats cached result {$_REQUEST['name']} " . json_encode($_getStats[$live_servers_id][$_REQUEST['name']]));
return $_getStats[$live_servers_id][$_REQUEST['name']];
}
session_write_close();
$obj = new stdClass();
$obj->error = true;
$obj->msg = "OFFLINE";
$obj->nclients = 0;
$obj->applications = array();
$obj->hidden_applications = array();
$obj->name = $_REQUEST['name'];
$liveUsersEnabled = AVideoPlugin::isEnabledByName("LiveUsers");
$p = AVideoPlugin::loadPlugin("Live");
$xml = $p->getStatsObject($live_servers_id);
$xml = json_encode($xml);
$xml = json_decode($xml);
$stream = false;
$lifeStream = array();
//$obj->server = $xml->server;
if (!empty($xml->server->application) && !is_array($xml->server->application)) {
$application = $xml->server->application;
$xml->server->application = array();
$xml->server->application[] = $application;
}
foreach ($xml->server->application as $key => $application) {
if (!empty($application->live->stream)) {
if (empty($lifeStream)) {
$lifeStream = array();
}
$stream = $application->live->stream;
if (empty($application->live->stream->name) && !empty($application->live->stream[0]->name)) {
foreach ($application->live->stream as $stream) {
$lifeStream[] = $stream;
}
} else {
$lifeStream[] = $application->live->stream;
}
}
}
$obj->disableGif = $p->getDisableGifThumbs();
$obj->countLiveStream = count($lifeStream);
foreach ($lifeStream as $value) {
if (!empty($value->name)) {
$row = LiveTransmition::keyExists($value->name);
if (empty($row['users_id'])) {
continue;
}
if (!empty($row) && $value->name === $obj->name) {
$obj->msg = "ONLINE";
}
$title = $row['title'];
$u = new User($row['users_id']);
$hiddenName = preg_replace('/^(.{5})/', '*****', $value->name);
-
+
if (!self::canSeeLiveFromLiveKey($value->name)) {
$obj->hidden_applications[] = "{$row['channelName']} ($hiddenName} is a private live";
if (!User::isAdmin()) {
continue;
} else {
$title .= " (private live)";
}
} else
if (empty($row) || empty($row['public'])) {
$obj->hidden_applications[] = "{$row['channelName']} ($hiddenName} is set to not be listed";
if (!User::isAdmin()) {
continue;
} else {
$title .= " (set to not be listed)";
}
} else
if ($u->getStatus() !== 'a') {
$obj->hidden_applications[] = "{$row['channelName']} {$hiddenName} the user is inactive";
if (!User::isAdmin()) {
continue;
} else {
$title .= " (user is inactive)";
}
}
$users = false;
if ($liveUsersEnabled) {
$filename = $global['systemRootPath'] . 'plugin/LiveUsers/Objects/LiveOnlineUsers.php';
if (file_exists($filename)) {
require_once $filename;
$liveUsers = new LiveOnlineUsers(0);
$users = $liveUsers->getUsersFromTransmitionKey($value->name, $live_servers_id);
}
}
$userName = $u->getNameIdentificationBd();
$user = $u->getUser();
$channelName = $u->getChannelName();
$photo = $u->getPhotoDB();
$poster = $global['webSiteRootURL'] . $p->getPosterImage($row['users_id'], $live_servers_id);
-
+
$playlists_id_live = 0;
- if(preg_match("/.*_([0-9]+)/", $value->name, $matches)){
- if(!empty($matches[1])){
+ if (preg_match("/.*_([0-9]+)/", $value->name, $matches)) {
+ if (!empty($matches[1])) {
$_REQUEST['playlists_id_live'] = intval($matches[1]);
$playlists_id_live = $_REQUEST['playlists_id_live'];
$photo = PlayLists::getImage($_REQUEST['playlists_id_live']);
$title = PlayLists::getNameOrSerieTitle($_REQUEST['playlists_id_live']);
}
}
-
+
$link = Live::getLinkToLiveFromChannelNameAndLiveServer($u->getChannelName(), $live_servers_id);
// this variable is to keep it compatible for Mobile app
$UserPhoto = $photo;
$obj->applications[] = array(
"key" => LiveTransmition::keyNameFix($value->name),
"isPrivate" => self::isAPrivateLiveFromLiveKey($value->name),
"users" => $users,
"name" => $userName,
"user" => $user,
"photo" => $photo,
"UserPhoto" => $UserPhoto,
"title" => $title,
'channelName' => $channelName,
'poster' => $poster,
'link' => $link . (strpos($link, '?') !== false ? "&embed=1" : "?embed=1"),
'href' => $link,
'playlists_id_live' => $playlists_id_live
);
if ($value->name === $obj->name) {
$obj->error = property_exists($value, 'publishing') ? false : true;
$obj->msg = (!$obj->error) ? "ONLINE" : "Waiting for Streamer";
$obj->stream = $value;
$obj->nclients = intval($value->nclients);
break;
}
}
}
$obj->error = false;
$_getStats[$live_servers_id][$_REQUEST['name']] = $obj;
//_error_log("Live::_getStats NON cached result {$_REQUEST['name']} " . json_encode($obj));
return $obj;
}
+ static function getImage($users_id, $live_servers_id, $playlists_id_live = 0) {
+ $p = AVideoPlugin::loadPlugin("Live");
+ if (self::isLive($users_id)) {
+ $url = $p->getLivePosterImage($users_id, $live_servers_id);
+ $url = addQueryStringParameter($url, "playlists_id_live", $playlists_id_live);
+ } else {
+ $file = self::getOfflineImage(false);
+ }
+ return $url;
+ }
+
+ static function isLive($users_id, $live_servers_id = 0) {
+ if(empty($users_id)){
+ return false;
+ }
+ $key = self::getLiveKey($users_id);
+ $json = self::getStats();
+ if (!empty($json) && is_object($json) && !empty($json->applications)) {
+ foreach ($json->applications as $value) {
+ if (preg_match("/{$key}.*/", $value['key'])) {
+ if (empty($live_servers_id)) {
+ return true;
+ } else {
+ if ($value['live_servers_id'] == $live_servers_id) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ static function getOnlineLivesFromUser($users_id) {
+ $key = self::getLiveKey($users_id);
+ $json = self::getStats();
+ $lives = array();
+ if (!empty($json) && is_object($json) && !empty($json->applications)) {
+ foreach ($json->applications as $value) {
+ if (preg_match("/{$key}.*/", $value['key'])) {
+ $lives[] = $value;
+ }
+ }
+ }
+ return $lives;
+ }
+
+ static function keyIsFromPlaylist($key) {
+ $parts = explode("_", $key);
+ if (empty($parts[1])) {
+ return false;
+ }
+ return array('key' => $parts[0], 'playlists_id' => $parts[1]);
+ }
+
+ static function getLiveKey($users_id) {
+ $lt = new LiveTransmition(0);
+ $lt->loadByUser($users_id);
+ return $lt->getKey();
+ }
+
+ public function getImageGif($users_id, $live_servers_id = 0, $playlists_id_live = 0) {
+ global $global;
+ if (empty($live_servers_id)) {
+ $live_servers_id = self::getCurrentLiveServersId();
+ }
+ $u = new User($users_id);
+ $username = $u->getUserName();
+ $file = "plugin/Live/getImage.php?live_servers_id={$live_servers_id}&u={$username}&format=gif";
+ $url = $global['webSiteRootURL'] . $file;
+ $url = addQueryStringParameter($url, "playlists_id_live", $playlists_id_live);
+ return $url;
+ }
+
public function getPosterImage($users_id, $live_servers_id) {
global $global;
$file = self::_getPosterImage($users_id, $live_servers_id);
if (!file_exists($global['systemRootPath'] . $file)) {
$file = "plugin/Live/view/OnAir.jpg";
}
return $file;
}
public function getLivePosterImage($users_id, $live_servers_id = 0) {
global $global;
return $global['webSiteRootURL'] . self::getLivePosterImageRelativePath($users_id, $live_servers_id);
}
public function getLivePosterImageRelativePath($users_id, $live_servers_id = 0) {
global $global;
if (empty($live_servers_id)) {
$live_servers_id = self::getCurrentLiveServersId();
}
if (self::isLiveThumbsDisabled()) {
$file = self::_getPosterImage($users_id, $live_servers_id);
if (!file_exists($global['systemRootPath'] . $file)) {
$file = "plugin/Live/view/OnAir.jpg";
}
} else {
$u = new User($users_id);
$username = $u->getUserName();
$file = "plugin/Live/getImage.php?live_servers_id={$live_servers_id}&u={$username}&format=jpg";
}
return $file;
}
public static function isLiveThumbsDisabled() {
$obj = AVideoPlugin::getDataObject("Live");
if (!empty($obj->disableLiveThumbs)) {
return true;
}
return false;
}
public function getPosterThumbsImage($users_id, $live_servers_id) {
global $global;
$file = self::_getPosterThumbsImage($users_id, $live_servers_id);
-
+
if (!file_exists($global['systemRootPath'] . $file)) {
- $file = "plugin/Live/view/OnAir.jpg";
+ $file = self::getOnAirImage(false);
}
return $file;
}
+ static function getOfflineImage($includeURL = true) {
+ global $global;
+ $img = "plugin/Live/view/Offline.jpg";
+ if ($includeURL) {
+ $img = "{$global['webSiteRootURL']}{$img}";
+ }
+ return $img;
+ }
+
+ static function getOnAirImage($includeURL = true) {
+ global $global;
+ $img = "plugin/Live/view/Offline.jpg";
+ if ($includeURL) {
+ $img = "{$global['webSiteRootURL']}{$img}";
+ }
+ return $img;
+ }
+
public function _getPosterImage($users_id, $live_servers_id) {
$file = "videos/userPhoto/Live/user_{$users_id}_bg_{$live_servers_id}.jpg";
return $file;
}
public function _getPosterThumbsImage($users_id, $live_servers_id) {
$file = "videos/userPhoto/Live/user_{$users_id}_thumbs_{$live_servers_id}.jpg";
return $file;
}
public static function on_publish($liveTransmitionHistory_id) {
$obj = AVideoPlugin::getDataObject("Live");
if (empty($obj->disableRestream)) {
self::restream($liveTransmitionHistory_id);
}
}
public static function getRestreamObject($liveTransmitionHistory_id) {
if (empty($liveTransmitionHistory_id)) {
return false;
}
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
if (empty($lth->getKey())) {
return false;
}
$_REQUEST['live_servers_id'] = $lth->getLive_servers_id();
$obj = new stdClass();
$obj->m3u8 = self::getM3U8File($lth->getKey(), true);
$obj->restreamerURL = self::getRestreamer($lth->getLive_servers_id());
$obj->restreamsDestinations = array();
$obj->token = getToken(60);
$obj->users_id = $lth->getUsers_id();
$rows = Live_restreams::getAllFromUser($lth->getUsers_id());
foreach ($rows as $value) {
$value['stream_url'] = rtrim($value['stream_url'], "/") . '/';
$obj->restreamsDestinations[] = "{$value['stream_url']}{$value['stream_key']}";
}
return $obj;
}
public static function restream($liveTransmitionHistory_id) {
ignore_user_abort(true);
ob_start();
header("Connection: close");
@header("Content-Length: " . ob_get_length());
ob_end_flush();
flush();
try {
$obj = self::getRestreamObject($liveTransmitionHistory_id);
if (empty($obj)) {
return false;
}
$data_string = json_encode($obj);
_error_log("Live:restream ({$obj->restreamerURL}) {$data_string}");
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $obj->restreamerURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
} catch (Exception $exc) {
_error_log("Live:restream " . $exc->getTraceAsString());
}
return false;
}
public static function canStreamWithMeet() {
if (!User::canStream()) {
return false;
}
if (!User::canCreateMeet()) {
return false;
}
$mobj = AVideoPlugin::getObjectDataIfEnabled("Meet");
if (empty($mobj)) {
return false;
}
$obj = AVideoPlugin::getObjectDataIfEnabled("Live");
if (!empty($obj->disableMeetCamera)) {
return false;
}
return true;
}
public function getUploadMenuButton() {
global $global;
$obj = $this->getDataObject();
if (!empty($obj->doNotShowGoLiveButton) || !User::canStream()) {
return '';
}
$buttonTitle = $this->getButtonTitle();
//include $global['systemRootPath'] . 'plugin/Live/getUploadMenuButton.php';
}
+ public static function getAllVideos($status = "", $showOnlyLoggedUserVideos = false, $activeUsersOnly = true) {
+ global $global, $config, $advancedCustom;
+ if (AVideoPlugin::isEnabledByName("VideoTags")) {
+ if (!empty($_GET['tags_id']) && empty($videosArrayId)) {
+ TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})");
+ $videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']);
+ TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__);
+ }
+ }
+ $status = str_replace("'", "", $status);
+
+ $sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified "
+ . " FROM live_transmitions as v "
+ . " LEFT JOIN categories c ON categories_id = c.id "
+ . " LEFT JOIN users u ON v.users_id = u.id "
+ . " WHERE 1=1 ";
+
+ if ($showOnlyLoggedUserVideos === true && !Permissions::canModerateVideos()) {
+ $uid = intval(User::getId());
+ $sql .= " AND v.users_id = '{$uid}'";
+ } elseif (!empty($showOnlyLoggedUserVideos)) {
+ $uid = intval($showOnlyLoggedUserVideos);
+ $sql .= " AND v.users_id = '{$uid}'";
+ } elseif (!empty($_GET['channelName'])) {
+ $user = User::getChannelOwner($_GET['channelName']);
+ $uid = intval($user['id']);
+ $sql .= " AND v.users_id = '{$uid}' ";
+ }
+
+ if ($activeUsersOnly) {
+ $sql .= " AND u.status = 'a' ";
+ }
+
+ if ($status == "publicOnly") {
+ $sql .= " AND v.public = 1 ";
+ } elseif (!empty($status)) {
+ $sql .= " AND v.`public` = '{$status}'";
+ }
+
+ if (!empty($_GET['catName'])) {
+ $sql .= " AND (c.clean_name = '{$_GET['catName']}' OR c.parentId IN (SELECT cs.id from categories cs where cs.clean_name = '{$_GET['catName']}' ))";
+ }
+
+ if (!empty($_GET['modified'])) {
+ $_GET['modified'] = str_replace("'", "", $_GET['modified']);
+ $sql .= " AND v.modified >= '{$_GET['modified']}'";
+ }
+
+ $sql .= AVideoPlugin::getVideoWhereClause();
+
+ if (strpos(strtolower($sql), 'limit') === false) {
+ if (!empty($_GET['limitOnceToOne'])) {
+ $sql .= " LIMIT 1";
+ unset($_GET['limitOnceToOne']);
+ }
+ $_REQUEST['rowCount'] = getRowCount();
+ if (!empty($_REQUEST['rowCount'])) {
+ $sql .= " LIMIT {$_REQUEST['rowCount']}";
+ } else {
+ _error_log("getAllVideos without limit " . json_encode(debug_backtrace()));
+ if (empty($global['limitForUnlimitedVideos'])) {
+ $global['limitForUnlimitedVideos'] = 100;
+ }
+ if ($global['limitForUnlimitedVideos'] > 0) {
+ $sql .= " LIMIT {$global['limitForUnlimitedVideos']}";
+ }
+ }
+ }
+
+ //echo $sql;exit;
+ //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
+ $res = sqlDAL::readSql($sql);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+
+ sqlDAL::close($res);
+ $videos = array();
+ if ($res != false) {
+ foreach ($fullData as $row) {
+ unset($row['password']);
+ unset($row['recoverPass']);
+
+ $row['live_servers_id'] = self::getLastServersIdFromUser($row['users_id']);
+
+ if (empty($otherInfo)) {
+ $otherInfo = array();
+ $otherInfo['category'] = xss_esc_back($row['category']);
+ $otherInfo['groups'] = UserGroups::getVideoGroups($row['id']);
+ //$otherInfo['title'] = UTF8encode($row['title']);
+ $otherInfo['description'] = UTF8encode($row['description']);
+ $otherInfo['descriptionHTML'] = Video::htmlDescription($otherInfo['description']);
+ $otherInfo['filesize'] = 0;
+ }
+
+ foreach ($otherInfo as $key => $value) {
+ $row[$key] = $value;
+ }
+
+ $row['rotation'] = 0;
+ $row['filename'] = '';
+ $row['type'] = 'live';
+ $row['duration'] = '';
+ $row['isWatchLater'] = 0;
+ $row['isFavorite'] = 0;
+ $row['views_count'] = 0;
+
+ $videos[] = $row;
+ }
+ //$videos = $res->fetch_all(MYSQLI_ASSOC);
+ } else {
+ $videos = false;
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+ return $videos;
+ }
+
}
diff --git a/plugin/Live/Objects/LiveTransmition.php b/plugin/Live/Objects/LiveTransmition.php
index db48be927..b020fd938 100644
--- a/plugin/Live/Objects/LiveTransmition.php
+++ b/plugin/Live/Objects/LiveTransmition.php
@@ -1,307 +1,310 @@
id;
}
function getTitle() {
return $this->title;
}
function getPublic() {
return $this->public;
}
function getSaveTransmition() {
return $this->saveTransmition;
}
function getUsers_id() {
return $this->users_id;
}
function getCategories_id() {
return $this->categories_id;
}
function getKey() {
return $this->key;
}
function getDescription() {
return $this->description;
}
function setId($id) {
$this->id = $id;
}
function setTitle($title) {
global $global;
//$title = $global['mysqli']->real_escape_string($title);
$this->title = xss_esc($title);
}
function setPublic($public) {
$this->public = intval($public);
}
function setSaveTransmition($saveTransmition) {
$this->saveTransmition = $saveTransmition;
}
function setUsers_id($users_id) {
$this->users_id = $users_id;
}
function setCategories_id($categories_id) {
$this->categories_id = $categories_id;
}
function setKey($key) {
$this->key = $key;
}
function setDescription($description) {
global $global;
//$description = $global['mysqli']->real_escape_string($description);
$this->description = xss_esc($description);
}
function loadByUser($user_id) {
$user = self::getFromDbByUser($user_id);
if (empty($user))
return false;
foreach ($user as $key => $value) {
$this->$key = $value;
}
return true;
}
function loadByKey($uuid) {
$row = self::getFromKey($uuid);
if (empty($row))
return false;
foreach ($row as $key => $value) {
$this->$key = $value;
}
return true;
}
static function getFromDbByUser($user_id) {
global $global;
$user_id = intval($user_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($user_id), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res != false) {
$user = $data;
} else {
$user = false;
}
return $user;
}
static function createTransmitionIfNeed($user_id) {
if (empty($user_id)) {
return false;
}
$row = static::getFromDbByUser($user_id);
if ($row) {
return $row;
}
$l = new LiveTransmition(0);
$l->setTitle("Empty Title");
$l->setDescription("");
$l->setKey(uniqid());
$l->setCategories_id(1);
$l->setUsers_id($user_id);
$l->save();
return static::getFromDbByUser($user_id);
}
static function resetTransmitionKey($user_id) {
$row = static::getFromDbByUser($user_id);
$l = new LiveTransmition($row['id']);
$newKey = uniqid();
$l->setKey($newKey);
if($l->save()){
return $newKey;
}else{
return false;
}
}
static function getFromDbByUserName($userName) {
global $global;
$userName = $global['mysqli']->real_escape_string($userName);
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($userName), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res != false) {
$user = $data;
+ if(empty($user)){
+ return false;
+ }
return static::getFromDbByUser($user['id']);
} else {
return false;
}
}
static function keyExists($key) {
global $global;
if (!is_string($key)) {
return false;
}
$parts = explode("_", $key);
if(!empty($parts[1])){
$adaptive = array('hi', 'low', 'mid');
if(in_array($parts[1], $adaptive)){
return false;
}
}
$key = $parts[0];
$key = preg_replace("/[^A-Za-z0-9]/", '', $key);
$sql = "SELECT u.*, lt.* FROM " . static::getTableName() . " lt "
. " LEFT JOIN users u ON u.id = users_id AND u.status='a' WHERE `key` = '$key' LIMIT 1";
$res = sqlDAL::readSql($sql);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
} else {
$row = false;
}
return $row;
}
function save() {
$this->public = intval($this->public);
$this->saveTransmition = intval($this->saveTransmition);
$this->showOnTV = intval($this->showOnTV);
$id = parent::save();
Category::clearCacheCount();
return $id;
}
function deleteGroupsTrasmition() {
if (empty($this->id)) {
return false;
}
global $global;
$sql = "DELETE FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
return sqlDAL::writeSql($sql, "i", array($this->id));
}
function insertGroup($users_groups_id) {
global $global;
$sql = "INSERT INTO live_transmitions_has_users_groups (live_transmitions_id, users_groups_id) VALUES (?,?)";
return sqlDAL::writeSql($sql, "ii", array($this->id, $users_groups_id));
}
function isAPrivateLive(){
return !empty($this->getGroups());
}
function getGroups() {
$rows = array();
if (empty($this->id)) {
return $rows;
}
global $global;
$sql = "SELECT * FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
$res = sqlDAL::readSql($sql, "i", array($this->id));
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row["users_groups_id"];
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
function userCanSeeTransmition() {
global $global;
require_once $global['systemRootPath'] . 'objects/userGroups.php';
require_once $global['systemRootPath'] . 'objects/user.php';
if (User::isAdmin()) {
return true;
}
$transmitionGroups = $this->getGroups();
if (!empty($transmitionGroups)) {
if (empty($this->id)) {
return false;
}
if (!User::isLogged()) {
return false;
}
$userGroups = UserGroups::getUserGroups(User::getId());
if (empty($userGroups)) {
return false;
}
foreach ($userGroups as $ugvalue) {
foreach ($transmitionGroups as $tgvalue) {
if ($ugvalue['id'] == $tgvalue) {
return true;
}
}
}
return false;
} else {
return true;
}
}
static function getFromKey($key) {
global $global;
$sql = "SELECT * FROM " . static::getTableName() . " WHERE `key` = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($key), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res != false) {
$user = $data;
} else {
$user = false;
}
return $user;
}
static function keyNameFix($key){
if(!empty($_REQUEST['playlists_id_live']) && !preg_match("/.*_([0-9]+)/", $key)){
$key .= "_{$_REQUEST['playlists_id_live']}";
}
return $key;
}
function getShowOnTV() {
return $this->showOnTV;
}
function setShowOnTV($showOnTV) {
$this->showOnTV = $showOnTV;
}
}
diff --git a/plugin/Live/getImage.php b/plugin/Live/getImage.php
index 5fcc8fc96..583c28ab9 100644
--- a/plugin/Live/getImage.php
+++ b/plugin/Live/getImage.php
@@ -1,82 +1,99 @@
userCanSeeTransmition()){
$uuid = LiveTransmition::keyNameFix($livet['key']);
$p = AVideoPlugin::loadPlugin("Live");
$video = Live::getM3U8File($uuid);
$url = $config->getEncoderURL()."getImage/". base64_encode($video)."/{$_GET['format']}";
_error_log("Live:getImage $url");
if(!empty($_SESSION[$url]['content']) && strlen($_SESSION[$url]['content']) === 70808){
_error_log("Live:getImage It is the default image, unset it ");
_session_start();
unset($_SESSION[$url]);
}
if (empty($_SESSION[$url]['expire']) || $_SESSION[$url]['expire'] < time()) {
$content = url_get_contents($url);
_session_start();
_error_log("Live:getImage Image Expired in ". date("d/m/Y H:i:s", @$_SESSION[$url]['expire'])." NOW is ". date("d/m/Y H:i:s"));
$_SESSION[$url] = array('content' => $content, 'expire' => strtotime("+2 min"));
_error_log("Live:getImage New Image will Expired in ". date("d/m/Y H:i:s", $_SESSION[$url]['expire'])." NOW is ". date("d/m/Y H:i:s"));
}
if(!empty($_SESSION[$url]['content'])){
ob_end_clean();
- echo $_SESSION[$url]['content'];
+ if(strlen($_SESSION[$url]['content']) === 70808){
+ _error_log("Live:getImage It is the default image, try to show the poster ");
+ echo file_get_contents($filename);
+ }else{
+ echo $_SESSION[$url]['content'];
+ }
_error_log("Live:getImage Cached Good until ". date("d/m/Y H:i:s", $_SESSION[$url]['expire'])." NOW is ". date("d/m/Y H:i:s")." strlen: ". strlen($_SESSION[$url]['content']));
}else{
ob_end_clean();
echo file_get_contents($filename);
_error_log("Live:getImage Get default image ");
}
}else{
_error_log("Live:getImage Can not see the image");
}
$p = AVideoPlugin::loadPluginIfEnabled("Cache");
if(!empty($p)){
$p->getEnd();
}
\ No newline at end of file
diff --git a/plugin/LiveLinks/LiveLinks.php b/plugin/LiveLinks/LiveLinks.php
index 19bc616b0..d94051ca6 100644
--- a/plugin/LiveLinks/LiveLinks.php
+++ b/plugin/LiveLinks/LiveLinks.php
@@ -1,234 +1,373 @@
isReadyLabel(array('Live'));
$help = " Help";
return $desc.$help;
}
public function getName() {
return "LiveLinks";
}
public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->onlyAdminCanAddLinks = true;
$obj->buttonTitle = "Add a Live Link";
$obj->disableGifThumbs = false;
$obj->disableLiveThumbs = false;
$obj->doNotShowLiveLinksLabel = false;
$obj->disableProxy = false;
return $obj;
}
public function getUUID() {
return "39d3b5fe-9702-4f1d-9ffd-fe1cd22a4dc7";
}
public function getPluginVersion() {
- return "2.0";
+ return "3.0";
}
public function canAddLinks() {
$obj = $this->getDataObject();
if (!User::isLogged()) {
return false;
}
if ($obj->onlyAdminCanAddLinks && !User::isAdmin()) {
return false;
}
return User::canStream();
}
public function getHTMLMenuRight() {
global $global;
$obj = $this->getDataObject();
if (!$this->canAddLinks()) {
return '';
}
include $global['systemRootPath'] . 'plugin/LiveLinks/view/menuRight.php';
}
static function getAllActive() {
global $global;
$sql = "SELECT * FROM LiveLinks WHERE status='a' AND start_date <= now() AND end_date >= now() ORDER BY start_date ";
$res = $global['mysqli']->query($sql);
$rows = array();
if ($res) {
while ($row = $res->fetch_assoc()) {
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
+
+
+ static function getImage($id) {
+ global $global;
+ return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=jpg";
+ }
+
+ static function getImageGif($id) {
+ global $global;
+ return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=gif";
+ }
/**
*
* @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>''));
*/
public function getLiveApplicationArray() {
global $global;
$obj = $this->getDataObject();
$filename = $global['systemRootPath'] . 'plugin/LiveLinks/view/menuItem.html';
$filenameExtra = $global['systemRootPath'] . 'plugin/LiveLinks/view/extraItem.html';
$filenameExtraVideoPage = $global['systemRootPath'] . 'plugin/LiveLinks/view/extraItemVideoPage.html';
$row = LiveLinks::getAllActive();
$array = array();
$search = array(
'_unique_id_',
'_user_photo_',
'_title_',
'_user_identification_',
'_description_',
'_link_',
'_imgJPG_',
'_imgGIF_',
'_class_'
);
$content = file_get_contents($filename);
$contentExtra = file_get_contents($filenameExtra);
$contentExtraVideoPage = file_get_contents($filenameExtraVideoPage);
if(empty($_GET['requestComesFromVideoPage'])){
$regex = "/".addcslashes($global['webSiteRootURL'],"/")."video\/.*/";
$requestComesFromVideoPage = preg_match($regex, @$_SERVER["HTTP_REFERER"]);
}else{
$requestComesFromVideoPage = 1;
}
foreach ($row as $value) {
if($value['type']=='unlisted'){
continue;
}
if($value['type']=='logged_only'){
if(!User::isLogged()){
continue;
}
}
$UserPhoto = User::getPhoto($value['users_id']);
$name = User::getNameIdentificationById($value['users_id']);
$replace = array(
$value['id'],
$UserPhoto,
$value['title'],
$name,
str_replace('"', "", $value['description']),
self::getLink($value['id']),
'',
empty($obj->disableGifThumbs)?(''):"",
($requestComesFromVideoPage)?"col-xs-6":"col-lg-2 col-md-4 col-sm-4 col-xs-6"
);
$newContent = str_replace($search, $replace, $content);
$newContentExtra = str_replace($search, $replace, $contentExtra);
$newContentExtraVideoPage = str_replace($search, $replace, $contentExtraVideoPage);
$array[] = array(
"type" => "LiveLink",
"html" => $newContent,
"htmlExtra" => $newContentExtra,
"htmlExtraVideoPage" => $newContentExtraVideoPage,
"UserPhoto" => $UserPhoto,
"title" => $value['title'],
"name" => $name,
"poster" => self::getPosterToLiveFromId($value['id']),
"link" => self::getLinkToLiveFromId($value['id'], true)
);
}
return $array;
}
public function updateScript() {
- global $global;
- sqlDal::writeSql(file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV2.0.sql'));
+ global $global;
+ if (AVideoPlugin::compareVersion($this->getName(), "2") < 0) {
+ $sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV2.0.sql');
+ $sqlParts = explode(";", $sqls);
+ foreach ($sqlParts as $value) {
+ sqlDal::writeSql(trim($value));
+ }
+ }
+ if (AVideoPlugin::compareVersion($this->getName(), "3") < 0) {
+ $sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV3.0.sql');
+ $sqlParts = explode(";", $sqls);
+ foreach ($sqlParts as $value) {
+ sqlDal::writeSql(trim($value));
+ }
+ }
+
return true;
}
public function getHeadCode() {
global $global;
$obj = $this->getDataObject();
// preload image
$js = "";
$css = '';
if(!empty($obj->doNotShowLiveLinksLabel)){
$css .= '';
}
return $js.$css;
}
public function getLinkToLiveFromId($id, $embed=false){
return self::getLink($id, $embed);
}
public static function getLink($id, $embed=false){
global $global;
//return "{$global['webSiteRootURL']}plugin/LiveLinks/view/Live.php?link={$id}".($embed?"&embed=1":"");
$ll = new LiveLinksTable($id);
if(!$embed){
return "{$global['webSiteRootURL']}liveLink/{$id}/". urlencode(cleanURLName($ll->getTitle()));
}else{
return "{$global['webSiteRootURL']}liveLinkEmbed/{$id}/". urlencode(cleanURLName($ll->getTitle()));
}
}
public function getPosterToLiveFromId($id){
global $global;
return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=jpg";
}
public static function isLiveThumbsDisabled(){
$obj = AVideoPlugin::getDataObject("LiveLinks");
if(!empty($obj->disableLiveThumbs)){
return true;
}
return false;
}
public function getPosterThumbsImage($users_id, $live_servers_id) {
global $global;
$file = Live::_getPosterThumbsImage($users_id, $live_servers_id);
if (!file_exists($global['systemRootPath'] . $file)) {
$file = "plugin/Live/view/OnAir.jpg";
}
return $file;
}
public function getUploadMenuButton() {
global $global;
if (!$this->canAddLinks()) {
return '';
}
$obj = $this->getDataObject();
$buttonTitle = $obj->buttonTitle;
//include $global['systemRootPath'] . 'plugin/LiveLinks/getUploadMenuButton.php';
}
+
+
+
+ public static function getAllVideos($status = "", $showOnlyLoggedUserVideos = false, $activeUsersOnly = true) {
+ global $global, $config, $advancedCustom;
+ if (AVideoPlugin::isEnabledByName("VideoTags")) {
+ if (!empty($_GET['tags_id']) && empty($videosArrayId)) {
+ TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})");
+ $videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']);
+ TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__);
+ }
+ }
+ $status = str_replace("'", "", $status);
+
+ $sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified "
+ . " FROM livelinks as v "
+ . " LEFT JOIN categories c ON categories_id = c.id "
+ . " LEFT JOIN users u ON v.users_id = u.id "
+ . " WHERE 1=1 ";
+
+ if ($showOnlyLoggedUserVideos === true && !Permissions::canModerateVideos()) {
+ $uid = intval(User::getId());
+ $sql .= " AND v.users_id = '{$uid}'";
+ } elseif (!empty($showOnlyLoggedUserVideos)) {
+ $uid = intval($showOnlyLoggedUserVideos);
+ $sql .= " AND v.users_id = '{$uid}'";
+ } elseif (!empty($_GET['channelName'])) {
+ $user = User::getChannelOwner($_GET['channelName']);
+ $uid = intval($user['id']);
+ $sql .= " AND v.users_id = '{$uid}' ";
+ }
+
+ if ($activeUsersOnly) {
+ $sql .= " AND u.status = 'a' ";
+ }
+
+ if ($status == "publicOnly") {
+ $sql .= " AND v.`type` = 1 ";
+ } elseif (!empty($status)) {
+ $sql .= " AND v.`type` = '{$status}'";
+ }
+
+ if (!empty($_GET['catName'])) {
+ $sql .= " AND (c.clean_name = '{$_GET['catName']}' OR c.parentId IN (SELECT cs.id from categories cs where cs.clean_name = '{$_GET['catName']}' ))";
+ }
+
+ if (!empty($_GET['modified'])) {
+ $_GET['modified'] = str_replace("'", "", $_GET['modified']);
+ $sql .= " AND v.modified >= '{$_GET['modified']}'";
+ }
+
+ $sql .= AVideoPlugin::getVideoWhereClause();
+
+ if (strpos(strtolower($sql), 'limit') === false) {
+ if (!empty($_GET['limitOnceToOne'])) {
+ $sql .= " LIMIT 1";
+ unset($_GET['limitOnceToOne']);
+ }
+ $_REQUEST['rowCount'] = getRowCount();
+ if (!empty($_REQUEST['rowCount'])) {
+ $sql .= " LIMIT {$_REQUEST['rowCount']}";
+ } else {
+ _error_log("getAllVideos without limit " . json_encode(debug_backtrace()));
+ if (empty($global['limitForUnlimitedVideos'])) {
+ $global['limitForUnlimitedVideos'] = 100;
+ }
+ if ($global['limitForUnlimitedVideos'] > 0) {
+ $sql .= " LIMIT {$global['limitForUnlimitedVideos']}";
+ }
+ }
+ }
+
+ //echo $sql;exit;
+ //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
+ $res = sqlDAL::readSql($sql);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+
+ sqlDAL::close($res);
+ $videos = array();
+ if ($res != false) {
+ foreach ($fullData as $row) {
+ unset($row['password']);
+ unset($row['recoverPass']);
+ if (empty($otherInfo)) {
+ $otherInfo = array();
+ $otherInfo['category'] = xss_esc_back($row['category']);
+ $otherInfo['groups'] = UserGroups::getVideoGroups($row['id']);
+ //$otherInfo['title'] = UTF8encode($row['title']);
+ $otherInfo['description'] = UTF8encode($row['description']);
+ $otherInfo['descriptionHTML'] = Video::htmlDescription($otherInfo['description']);
+ $otherInfo['filesize'] = 0;
+ }
+
+ foreach ($otherInfo as $key => $value) {
+ $row[$key] = $value;
+ }
+
+ $row['rotation'] = 0;
+ $row['filename'] = '';
+ $row['type'] = 'livelinks';
+ $row['duration'] = '';
+ $row['isWatchLater'] = 0;
+ $row['isFavorite'] = 0;
+ $row['views_count'] = 0;
+
+ $videos[] = $row;
+ }
+ //$videos = $res->fetch_all(MYSQLI_ASSOC);
+ } else {
+ $videos = false;
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+ return $videos;
+ }
}
diff --git a/plugin/LiveLinks/Objects/LiveLinksTable.php b/plugin/LiveLinks/Objects/LiveLinksTable.php
index bdf3d419a..cbc775db8 100644
--- a/plugin/LiveLinks/Objects/LiveLinksTable.php
+++ b/plugin/LiveLinks/Objects/LiveLinksTable.php
@@ -1,99 +1,108 @@
users_id)){
$this->users_id = User::getId();
}
+ Category::clearCacheCount();
return parent::save();
}
function getId() {
return $this->id;
}
function getTitle() {
return $this->title;
}
function getDescription() {
return $this->description;
}
function getLink() {
return $this->link;
}
function getStart_date() {
return $this->start_date;
}
function getEnd_date() {
return $this->end_date;
}
function getType() {
return $this->type;
}
function getStatus() {
return $this->status;
}
function getUsers_id() {
return $this->users_id;
}
function setTitle($title) {
$this->title = $title;
}
function setDescription($description) {
$this->description = $description;
}
function setLink($link) {
$this->link = $link;
}
function setStart_date($start_date) {
$this->start_date = $start_date;
}
function setEnd_date($end_date) {
$this->end_date = $end_date;
}
function setType($type) {
$this->type = $type;
}
function setStatus($status) {
$this->status = $status;
}
function setUsers_id($users_id) {
$this->users_id = $users_id;
}
+ function getCategories_id() {
+ return $this->categories_id;
+ }
+
+ function setCategories_id($categories_id) {
+ $this->categories_id = intval($categories_id);
+ }
+
}
diff --git a/plugin/LiveLinks/Objects/livelinks.mwb b/plugin/LiveLinks/Objects/livelinks.mwb
new file mode 100644
index 000000000..552f92312
Binary files /dev/null and b/plugin/LiveLinks/Objects/livelinks.mwb differ
diff --git a/plugin/LiveLinks/Objects/livelinks.mwb.bak b/plugin/LiveLinks/Objects/livelinks.mwb.bak
new file mode 100644
index 000000000..cdfe86ce4
Binary files /dev/null and b/plugin/LiveLinks/Objects/livelinks.mwb.bak differ
diff --git a/plugin/LiveLinks/install/install.sql b/plugin/LiveLinks/install/install.sql
index 05b89ad4a..977e314b5 100644
--- a/plugin/LiveLinks/install/install.sql
+++ b/plugin/LiveLinks/install/install.sql
@@ -1,37 +1,43 @@
-- MySQL Workbench Synchronization
-- Generated: 2017-09-12 22:18
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: Daniel
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE TABLE IF NOT EXISTS `LiveLinks` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`link` TEXT NOT NULL,
`start_date` DATETIME NULL,
`end_date` DATETIME NULL,
`type` ENUM('public', 'unlisted', 'logged_only') NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
`status` ENUM('a', 'i') NULL DEFAULT 'a',
`users_id` INT NOT NULL,
+ `categories_id` INT NULL ,
PRIMARY KEY (`id`),
INDEX `fk_LiveLinks_users_idx` (`users_id` ASC),
- CONSTRAINT `fk_LiveLinks_users`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION)
+ ADD CONSTRAINT `fk_LiveLinks_users2`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ ADD CONSTRAINT `fk_livelinks_categories1`
+ FOREIGN KEY (`categories_id`)
+ REFERENCES `categories` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
diff --git a/plugin/LiveLinks/install/updateV3.0.sql b/plugin/LiveLinks/install/updateV3.0.sql
new file mode 100644
index 000000000..4aa65d424
--- /dev/null
+++ b/plugin/LiveLinks/install/updateV3.0.sql
@@ -0,0 +1,15 @@
+ALTER TABLE `livelinks`
+ADD COLUMN `categories_id` INT(11) NULL,
+ADD INDEX `fk_livelinks_categories1_idx` (`categories_id` ASC);
+
+ALTER TABLE `livelinks`
+ADD CONSTRAINT `fk_LiveLinks_users2`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ADD CONSTRAINT `fk_livelinks_categories1`
+ FOREIGN KEY (`categories_id`)
+ REFERENCES `categories` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/plugin/LiveLinks/view/addLiveLink.php b/plugin/LiveLinks/view/addLiveLink.php
index d6282b459..90a9c2156 100644
--- a/plugin/LiveLinks/view/addLiveLink.php
+++ b/plugin/LiveLinks/view/addLiveLink.php
@@ -1,29 +1,30 @@
error = true;
$obj->msg = "";
$plugin = AVideoPlugin::loadPluginIfEnabled('LiveLinks');
if(!$plugin->canAddLinks()){
$obj->msg = "You cant add links";
die(json_encode($obj));
}
$o = new LiveLinksTable(@$_POST['linkId']);
$o->setDescription($_POST['description']);
+$o->setCategories_id($_POST['categories_id']);
$o->setEnd_date($_POST['end_date']);
$o->setLink($_POST['link']);
$o->setStart_date($_POST['start_date']);
$o->setStatus($_POST['status']);
$o->setTitle($_POST['title']);
$o->setType($_POST['type']);
if($o->save()){
$obj->error = false;
}
echo json_encode($obj);
diff --git a/plugin/LiveLinks/view/panel.php b/plugin/LiveLinks/view/panel.php
index 8712f9234..a9dd30a63 100644
--- a/plugin/LiveLinks/view/panel.php
+++ b/plugin/LiveLinks/view/panel.php
@@ -1,206 +1,216 @@
Title
Start
End
Status
Type
Title
Start
End
Status
Type
\ No newline at end of file
diff --git a/plugin/PlayLists/PlayLists.php b/plugin/PlayLists/PlayLists.php
index 0bd2ac5ac..ec8974d98 100644
--- a/plugin/PlayLists/PlayLists.php
+++ b/plugin/PlayLists/PlayLists.php
@@ -1,737 +1,737 @@
"
. " You can use the Edit Parameters button to rename it to your choosing. We recommend to keep the Program name "
. "as it is defaulted to in order to be well indexed in the SearchTube and Other AVideo Platform search and network indexing tools.";
}
public function getName() {
return "Programs";
}
public function getUUID() {
return "plist12345-370-4b1f-977a-fd0e5cabtube";
}
public function getPluginVersion() {
return "1.0";
}
public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->name = "Program";
$obj->playOnSelect = true;
$obj->autoadvance = true;
$obj->usersCanOnlyCreatePlayListsFromTheirContent = false;
$obj->useOldPlayList = false;
$obj->expandPlayListOnChannels = false;
$obj->usePlaylistPlayerForSeries = true;
$obj->showWatchLaterOnLeftMenu = true;
$obj->showFavoriteOnLeftMenu = true;
$obj->showWatchLaterOnProfileMenu = true;
$obj->showFavoriteOnProfileMenu = true;
$obj->showPlayLiveButton = true;
$obj->showTrailerInThePlayList = true;
$obj->showTVFeatures = false;
return $obj;
}
public function getWatchActionButton($videos_id) {
global $global, $livet;
if (isLive() && empty($videos_id) && !empty($livet)) {
include $global['systemRootPath'] . 'plugin/PlayLists/actionButtonLive.php';
} else {
if (!self::canAddVideoOnPlaylist($videos_id)) {
return "";
}
$obj = $this->getDataObject();
//echo "getNetflixActionButton: ".$videos_id;
$btnClass = "btn btn-default no-outline";
include $global['systemRootPath'] . 'plugin/PlayLists/actionButton.php';
}
}
public function getNetflixActionButton($videos_id) {
global $global;
if (!self::canAddVideoOnPlaylist($videos_id)) {
return "";
}
$obj = $this->getDataObject();
//echo "getNetflixActionButton: ".$videos_id;
$btnClass = "btn btn-primary";
include $global['systemRootPath'] . 'plugin/PlayLists/actionButton.php';
}
public function getGalleryActionButton($videos_id) {
global $global;
if (!self::canAddVideoOnPlaylist($videos_id)) {
return "";
}
$obj = $this->getDataObject();
//echo "getNetflixActionButton: ".$videos_id;
$btnClass = "text-primary";
echo '
';
include $global['systemRootPath'] . 'plugin/PlayLists/actionButton.php';
echo '
';
}
public function getHeadCode() {
global $global;
$obj = $this->getDataObject();
$css = '';
$css .= '';
return $css;
}
public function getFooterCode() {
global $global;
$obj = $this->getDataObject();
include $global['systemRootPath'] . 'plugin/PlayLists/footer.php';
$js = '';
if(isEmbed()){
if(self::showTVFeatures()){
$js .= '';
}
}
if(isLive() && self::showTVFeatures()){
if(!empty($_REQUEST['playlists_id_live']) &&
!self::isPlaylistLive($_REQUEST['playlists_id_live']) &&
self::canManagePlaylist($_REQUEST['playlists_id_live'])){
$liveLink = PlayLists::getLiveLink($_REQUEST['playlists_id_live']);
$js .= '';
}
}
return $js;
}
static function canAddVideoOnPlaylist($videos_id) {
if (empty($videos_id)) {
return false;
}
$obj = AVideoPlugin::getObjectData("PlayLists");
if (!User::isAdmin() && $obj->usersCanOnlyCreatePlayListsFromTheirContent) {
if (User::isLogged()) {
$users_id = Video::getOwner($videos_id);
if (User::getId() == $users_id) {
return true;
}
}
return false;
}
return true;
}
static function isVideoOnFavorite($videos_id, $users_id) {
return PlayList::isVideoOnFavorite($videos_id, $users_id);
}
static function isVideoOnWatchLater($videos_id, $users_id) {
return PlayList::isVideoOnWatchLater($videos_id, $users_id);
}
static function getFavoriteIdFromUser($users_id) {
return PlayList::getFavoriteIdFromUser($users_id);
}
static function getWatchLaterIdFromUser($users_id) {
return PlayList::getWatchLaterIdFromUser($users_id);
}
static function getWatchLaterLink() {
if (!User::isLogged()) {
return "";
}
global $global;
return "{$global['webSiteRootURL']}watch-later";
}
static function getFavoriteLink() {
if (!User::isLogged()) {
return "";
}
global $global;
return "{$global['webSiteRootURL']}favorite";
}
public function thumbsOverlay($videos_id) {
global $global;
include $global['systemRootPath'] . 'plugin/PlayLists/buttons.php';
}
static function isPlayListASerie($serie_playlists_id) {
global $global, $config;
$serie_playlists_id = intval($serie_playlists_id);
$sql = "SELECT * FROM videos WHERE serie_playlists_id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($serie_playlists_id), true);
$video = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $video;
}
static function removeSerie($serie_playlists_id) {
$video = self::isPlayListASerie($serie_playlists_id);
if (!empty($video)) {
$video = new Video("", "", $video['id']);
$video->delete();
}
}
static function saveSerie($serie_playlists_id) {
$playlist = new PlayList($serie_playlists_id);
if (empty($playlist)) {
return false;
}
$video = self::isPlayListASerie($serie_playlists_id);
if (!empty($video)) {
$filename = $video['filename'];
$v = new Video("", "", $video['id']);
} else {
$filename = 'serie_playlists_' . uniqid();
$v = new Video("", $filename);
}
$v->setTitle($playlist->getName());
$v->setSerie_playlists_id($serie_playlists_id);
$v->setUsers_id($playlist->getUsers_id());
$v->setStatus('u');
$v->setFilename($filename);
$v->setType("serie");
return $v->save();
}
public function getStart() {
global $global;
if (!empty($_GET['videoName'])) {
$obj = $this->getDataObject();
if ($obj->usePlaylistPlayerForSeries) {
$video = Video::getVideoFromCleanTitle($_GET['videoName']);
if ($video['type'] == 'serie' && !empty($video['serie_playlists_id'])) {
if (basename($_SERVER["SCRIPT_FILENAME"]) == "videoEmbeded.php") {
$link = PlayLists::getLink($video['serie_playlists_id'], true);
} else {
$link = PlayLists::getLink($video['serie_playlists_id']);
}
header("Location: {$link}");
exit;
}
}
}
}
static function getLink($playlists_id, $embed = false) {
global $global;
$obj = AVideoPlugin::getObjectData("PlayLists");
if ($embed) {
return $global['webSiteRootURL'] . "plugin/PlayLists/embed.php?playlists_id=" . $playlists_id;
} else {
if (empty($obj->useOldPlayList)) {
return $global['webSiteRootURL'] . "plugin/PlayLists/player.php?playlists_id=" . $playlists_id;
} else {
return $global['webSiteRootURL'] . "program/" . $playlists_id;
}
}
}
public function navBarButtons() {
global $global;
$obj = AVideoPlugin::getObjectData("PlayLists");
$str = "";
if ($obj->showWatchLaterOnLeftMenu) {
$str .= '